package com.eraasoftware.npa.server;

import java.nio.ByteBuffer;

import com.eraasoftware.npa.client.Header;
import com.eraasoftware.npa.client.Header.ActionEnum;
import com.eraasoftware.npa.io.Serializer;

public class ServiceFactorySetting {

	Serializer serializer = Serializer.instance();
	ByteBuffer bb = ByteBuffer.allocate(50);

	public ByteBuffer getPingBytes() {

		Header header = new Header();
		header.setAction(ActionEnum.PING);
		return serializeHeader(header);
	}

	private ByteBuffer serializeHeader(Header header) {

		bb.clear();
		serializer.writeObject(bb, header);
		bb.flip();

		return bb;
	}

	public ByteBuffer getCreateNewClientsBytes(int nbClient) {
		Header header = new Header();
		header.setAction(ActionEnum.NEW_CLIENT);
		header.addParameter("nbClients", Integer.toString(nbClient));
		return serializeHeader(header);

	}

}
